package com.yanqu.road.server.cmd.activity.summergames.fromcross;

import com.yanqu.road.entity.log.summergames.LogSummerGamesExchange;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SummerGamesProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SUMMER_GAMES_EXCHANGE_APPLY_FROM_CROSS, desc = "提交交换请求(跨服返回)")
public class SummerGamesApplyExchangeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        SummerGamesProto.CrossSummerGamesApplyExchangeRespMsg respMsg = SummerGamesProto.CrossSummerGamesApplyExchangeRespMsg.parseFrom(packet.getBytes());

        //日志
        SummerGamesProto.SummerGamesExchangeInfoTemp info = respMsg.getInfo();
        AutoLogMgr.add(new LogSummerGamesExchange(
                respMsg.getActivityId(),
                player.getUserId(),
                info.getId(),
                0,
                info.getAppointUserId(),
                info.getProvideId(),
                info.getNeedId(),
                info.getType()
        ));

        SummerGamesProto.SummerGamesApplyExchangeRespMsg.Builder clientMsg = SummerGamesProto.SummerGamesApplyExchangeRespMsg.newBuilder();
        clientMsg.setRet(0);
        player.sendPacket(Protocol.U_SUMMER_GAMES_EXCHANGE_APPLY, clientMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
